﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace lianxi2
{
    public partial class uplod : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string fileName = FileUpload1.FileName;
                String fileFix = fileName.Substring(fileName.LastIndexOf('.') + 1).ToLower();
                if (fileFix != "png" && fileFix != "jpg" && fileFix != "jpeg" && fileFix != "pic")
                {
                    Label1.Attributes.Add("style", "color:#12b7f5");
                    this.Label1.Text = "选择的不是图片文件";
                }
                else
                {
                    FileUpload1.SaveAs(Server.MapPath(".") + "//img//" + fileName);
                    this.Image1.ImageUrl = "~/img/" + fileName;
                    Label1.Attributes.Add("style", "color:#12b7f5");
                    this.Label1.Text = "图片上传成功";

                }
            }
        }
    }
}